home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 37
/
Aminet 37 (2000)(Schatztruhe)[!][Jun 2000].iso
/
Aminet
/
dev
/
basic
/
Mildred.lha
/
lha
/
DispDemo.lha
/
DisplayDemo.asc
next >
Wrap
Text File
|
1999-03-01
|
8KB
|
92 lines
; DisplayDemo by Andreas Hakansson - AKA TJoMMe
; Shows how to setup a split screen display using
; Mildred. This could be used in a game with a
; two player mode.
;
; Original code by Mikkel lokke, but I have changed
; it a lot and adapted it for my use. Feel free to
; use it in your own programs.
WBStartup ; Dont foget if you make an exe
NoCli ; We dont need the CLI window
DEFTYPE.l ; Set default type to long
NEWTYPE.Data ; Setup an array that stores
Xpos.w ; some information about the
Ypos.w ; displays. Needed when we scroll
XVelo.b ; more then one display. Could
YVelo.b ; proberbly be done some other way
End NEWTYPE ; but this is tidy
MCPU MProcessor ; Tell mildred which cpu we have
Mc2pCPUmode MProcessor ; Tell mildred which c2p mode to use
MReserveBitmaps 1 ; We need one chunky bitmap
MReservec2pWindows 1 ; We need one c2p window
MBitmap 0,640,512 ; Setup a chunky bitmap
*pbb.l=AllocMem(640*512,#MEMF_PUBLIC) ; Grab som mem for chunky bitmap
If *pbb ; Check if we got it
CludgeBitMap 0,640,512,8,*pbb ; Create a planar bitmap
LoadBitMap 0,"M2P.ILBM",0 ; Load in our picture
MPlanar16ToBitmap 0,*pbb ; Copy it to our chunky bitmap
Free BitMap 0 ; Get ride of planar bitmap
FreeMem *pbb,640*512 ; Get ride of allocated mem
Else End ; Quit if we didnt get the memory
EndIf ;
Mc2pWindow 0,320,128,640,320,256 ;
Dim bmppnt.l(1) ; Planar bitmap pointer array
For n=0 To 1 ; Setup loop to create two bitmaps
bmppnt(n)=AllocMem(320*256,#MEMF_CHIP) ; Get some memory
If bmppnt(n) ; Check if we got it
CludgeBitMap n,320,256,8,bmppnt(n) ; Create a bitmap with it
Else End ; Quit if we didnt get the memory
EndIf ;
Next ;
Dim scrtaglst.TagItem(7) ; Setup a screen tag list
scrtaglst(0)\ti_Tag = #SA_Left,0 ; And fill it up
scrtaglst(1)\ti_Tag = #SA_Depth,8 ;
scrtaglst(2)\ti_Tag = #SA_Width,320 ;
scrtaglst(3)\ti_Tag = #SA_Height,256 ;
scrtaglst(4)\ti_Tag = #SA_BitMap,Addr BitMap(0) ;
scrtaglst(5)\ti_Tag = #SA_ShowTitle,0 ;
scrtaglst(6)\ti_Tag = #SA_Draggable,0 ;
scrtaglst(7)\ti_Tag = #TAG_END ; Dont forget this one
ScreenTags 0,"DisplayDEMO",&scrtaglst(0) ; Open our screen
ShowPalette 0 ; Show our palette
Dim View.Data(1) ; Create an array to old display info
For n=0 To 1 ; Setup loop to handle both displays
View(n)\Xpos = Rnd(317)+1 ; Random a horizontal start coord
View(n)\Ypos = Rnd(381)+1 ; Random a vertical start coord
View(n)\XVelo = 1 ; Set horizontal scroll speed
View(n)\YVelo = 1 ; Set vertical scroll speed
Next ;
Repeat ; Setup our main loop
VWait ; Wait for the next vbl
For n=0 To 1 ; Setup a loop to for both displays
Mc2p 0,MBitmapPtr(View(n)\Xpos,View(n)\Ypos,0),MGenericPtr(0,(n*128),bmppnt(dbuf),40) ; Copy chunky chunky to planar and
; place it correctly on screen
View(n)\Xpos + View(n)\XVelo ; Calculate next x position
View(n)\Ypos + View(n)\YVelo ; Calculate next y position
If View(n)\Xpos=319 OR View(n)\Xpos=1 Then View(n)\XVelo=-View(n)\XVelo ; Bounce if we've hit the edge
If View(n)\Ypos=383 OR View(n)\Ypos=1 Then View(n)\YVelo=-View(n)\YVelo ; Bounce if we've hit the edge
Next ;
ShowBitMap(dbuf) ; Show the hidden buffer
dbuf=1-dbuf ; Double buffer (0..1..0..1..)
Until RawStatus($45) ; If ESC is pressed then quit
End ; End our program